package com.example.mybatisplus.query;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.example.mybatisplus.pojo.Business;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;


@Data
public class BusinessQuery extends BaseQuery{

	private String businessName; //商家名称模糊搜索的条件
	private String businessAddress;//商家地址模糊搜索的条件

	@Override
	public Wrapper getQueryWrapper() {
		QueryWrapper<Business> businessQueryWrapper = new QueryWrapper<>();
		if (StringUtils.isNotEmpty(businessName)){
			businessQueryWrapper.like("businessName",businessName);
		}
		if(StringUtils.isNotEmpty(businessAddress)){
			businessQueryWrapper.like("businessAddress",businessAddress);
		}
		businessQueryWrapper.orderByDesc("businessId");
		return businessQueryWrapper;
	}
}
